<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>具体评教页面</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="${request.contextPath}/tces/index/amazeui/css/amazeui.min.css"/>
    <link rel="stylesheet" href="${request.contextPath}/tces/index/default/style.css"/>
    <script src="${request.contextPath}/tces/index/amazeui/js/jquery.min.js"></script>
    <script src="${request.contextPath}/tces/index/amazeui/js/amazeui.min.js"></script>
    <link rel="stylesheet" href="${request.contextPath}/tces/index/js/layer/mobile/need/layer.css" />
    <link rel="stylesheet" href="${request.contextPath}/tces/index/css/iCheck/custom.css" />
    <script src="${request.contextPath}/tces/index/js/layer/mobile/layer.js"></script>
    <script src="${request.contextPath}/tces/index/js/iCheck/icheck.min.js"></script>
</head>

<body>
<div class="container">
    <header data-am-widget="header" class="am-header am-header-default my-header">
        <div class="am-header-left am-header-nav">
            <a href="javascript:fanhui();" class="left-fanhui">
                <i class="am-header-icon am-icon-chevron-left"></i>
            </a>
        </div>
        <h1 class="am-header-title">
            <a href="#title-link" class="">填写问卷</a>
        </h1>
    </header>
    <div class="am-cf cart-panel">
        <form id="pjForm" action="" method="post" class="cart-list-panel">
            <input type="hidden" id="indicators" value="${indicators?size}">
            <input type="hidden" id="cpId" value="${cpId}">
            <input type="hidden" id="qId" value="${qId}">
            <ul class="am-avg-sm-1 cart-panel-ul">
                <!--      <for start="开始值" end="结束值" comparison="" step="步进值" name="循环变量名" >

                          </for>-->
                <#list indicators as indicator>
                    <li style="height: auto;">
                        <div class="infopanel" style="width: 100%;padding-top: 1px;">
                            <h2 style="margin: 0;font-size:1.2em;">${indicator_index +1}、${indicator.name}</h2>
                            <div style="margin: 7px 0px 8px 12px;" class="radio i-checks">
                                <h3 style="margin: 0;font-size: 1.6rem;">
                                    <label class="radio-inline">
                                        <input type="radio" name="xuanze${indicator_index +1}"  value='${indicator.weightA}'> A、${indicator.optionA!}
                                    </label>
                                </h3>
                                <h3 style="margin: 0;font-size: 1.6rem;">
                                    <label class="radio-inline">
                                        <input type="radio" name="xuanze${indicator_index +1}"  value='${indicator.weightB}'> B、${indicator.optionB!}
                                    </label>
                                </h3>
                                <h3 style="margin: 0;font-size: 1.6rem;">
                                    <label class="radio-inline">
                                        <input type="radio" name="xuanze${indicator_index +1}"  value='${indicator.weightC}'> C、${indicator.optionC!}
                                    </label>
                                </h3>
                                <h3 style="margin: 0;font-size: 1.6rem;">
                                    <label class="radio-inline">
                                        <input type="radio" name="xuanze${indicator_index +1}"  value='${indicator.weightD}'> D、${indicator.optionD!}
                                    </label>
                                </h3>
                            </div>
                        </div>
                    </li>
                </#list>
            </ul>
        </form>
    </div>

    <div class="cart-tool">
        <a class="am-btn am-btn-sm am-btn-success" href="javascript:fanhui();">
            <i class="am-icon-chevron-left"></i>
            返回
        </a>
        <a class="am-btn am-btn-sm am-btn-warning" href="javascript:void(0)">提交评教</a>
    </div>
</div>
<style>
    .layui-m-layercont {
        padding: 0px 0px 3px;
    }
</style>
<script>
    $(function(){
        $(".i-checks").iCheck({checkboxClass:"icheckbox_square-green",radioClass:"iradio_square-green"});
    })

    $(".am-btn-warning").click(function(){
        //获取表单序列为数组，以判断是否选完
        var len = $(".cart-list-panel").serializeArray().length;
        var indicatorslen = $("#indicators").val();
        if(len!=indicatorslen){
         layer.open({
         content: '<span style="font-size: 2rem;display: block;padding: 2px 0;">还有未选的选项喔</br>不能提交评教。</span>'
         ,style: 'background-color:#09C1FF; color:#fff; border:none;' //自定风格
         ,time: 5
         });
         return false;
         }
        var $defen = 0;
        var $arr = $(".cart-list-panel").serializeArray();
        for(var i = 0 ; i<$arr.length; i++){
            $defen += parseFloat($arr[i].value);
        }
        console.log($defen);//获取评教类别
        $.ajax({
            url: "/tces/comment",
            data:{
                'result' : $defen,
                'cpId' :$("#cpId").val(),
                'qid' :$("#qId").val()
            },//$("#pjForm").serialize()+'&',
            type: "POST",
            dataType: 'json',
            success: function(data){
                console.log(data)
                if (data.success) {
                    layer.open({
                        content: data.msg
                        ,style: 'background-color:#09C1FF; color:#fff; border:none;' //自定风格
                        ,time:2
                    });
                    setInterval(function(){
                        window.location.href="/tces/index.html";
                    },2100)
                } else {
                    layer.open({
                        content: data.msg
                        ,style: 'background-color:#09C1FF; color:#fff; border:none;' //自定风格
                        ,time:2
                    });
                    setInterval(function(){
                        window.location.reload();
                    },1500)
                }
            }
        });

    })

    function fanhui(){
        layer.open({
            title: [
                '提示',
                'background-color:#8DCE16; color:#fff;'
            ]
            ,anim: 'up'
            ,content: '<span style="font-size: 2rem;">当前评教未完成，确定要返回上一页吗？</span><br /><em style="color: red ;font-size: 12px">(提示：现在退出当前页，之前的评教将作废哦)</em>'
            ,btn: ['确定','继续评教']
            ,shadeClose: false
            ,yes: function(index){
                window.history.back();
            }
            ,no: function(index){
                layer.close(index)
            }

        });
    }
</script>
</body>
</html>
